﻿

#include <stdint.h>
#include <stdlib.h>
#include "modDataDef.h"

class ModbusRtuMaster
{
    public:
        //存返回发出的字节数组
        uint8_t   m_modBuf[64];
        uint16_t  m_modBufLen;
        //存解析返回的数据包
        ModParseResult m_modPaseResult;
        ModbusRtuMaster();
        ~ModbusRtuMaster();
        void read(uint8_t slaveAddress, uint16_t startAddress, uint16_t regNum);
        void write(uint8_t slaveAddress, uint16_t startAddress, uint16_t* regBuffer, uint16_t regNum);
        bool  parseReplyPack(uint8_t* replyBuf, int replyBufLen, uint8_t slaveAddress);
        static uint16_t crc16(uint8_t* buf, uint16_t len);
        static int crcCheck(const uint8_t* buf, uint32_t len);
};




